    <script type="text/javascript">
		var url;
		function newUser(){
        $('#dlg').dialog('open').dialog('setTitle','新建客户信息');
        $('#fm').form('clear');
        url = 'save_user.php';
		}
		function editUser(){
			var row = $('#dg').datagrid('getSelected');
			if (row){
				$('#dlg').dialog('open').dialog('setTitle','Edit User');
				$('#fm').form('load',row);
				url = 'update_user.php?id='+row.id;
			}
		}
		function saveUser(){
			$('#fm').form('submit',{
				url: url,
				onSubmit: function(){
					return $(this).form('validate');
				},
				success: function(result){
					var result = eval('('+result+')');
					if (result.success){
						$('#dlg').dialog('close');		// close the dialog
						$('#dg').datagrid('reload');	// reload the user data
					} else {
						$.messager.show({
							title: 'Error',
							msg: result.msg
						});
					}
				}
			});
		}
		function removeUser(){
			var row = $('#dg').datagrid('getSelected');
			if (row){
				$.messager.confirm('Confirm','Are you sure you want to remove this user?',function(r){
					if (r){
						$.post('remove_user.php',{id:row.id},function(result){
							if (result.success){
								$('#dg').datagrid('reload');	// reload the user data
							} else {
								$.messager.show({	// show error message
									title: 'Error',
									msg: result.msg
								});
							}
						},'json');
					}
				});
			}
		}
	</script>
	
	<style type="text/css">
		#fm{
			margin:0;
			padding:10px 30px;
		}
		.ftitle{
			font-size:14px;
			font-weight:bold;
			color:#666;
			padding:5px 0;
			margin-bottom:10px;
			border-bottom:1px solid #ccc;
		}
		.fitem{
			margin-bottom:5px;
		}
		.fitem label{
			display:inline-block;
			width:80px;
		}
	</style>
	
	
	<h2>客户表</h2>
    <p>Click the buttons on datagrid toolbar to do crud actions.</p>
    
    <table id="dg" title="客户联系表" class="easyui-datagrid" style="width:1600px;height:800px"
            url="http://<?php echo base_url(); ?>index.php/client/easyui_get"
            toolbar="#toolbar" pagination="true"
            rownumbers="true" fitColumns="true" singleSelect="true">
        <thead>
            <tr>
                <th field="contact_by" width="50">负责人</th>
                <th field="country" width="50">国家</th>
                <th field="client_name" width="50">客户名</th>
                <th field="website" width="50">网址</th>
				<th field="client_type" width="50">客户类别</th>
				<th field="sector" width="50">行业</th>
            </tr>
        </thead>
    </table>
    <div id="toolbar">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">新建</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">编辑</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除</a>
    </div>
    
    <!--Creat form!-->
	<div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
            closed="true" buttons="#dlg-buttons">
        <div class="ftitle">客户信息</div>
        <form id="fm" method="post" novalidate>
            <div class="fitem">
                <label>负责人：</label>
                <input name="contact_by" class="easyui-textbox" required="true">
            </div>
            <div class="fitem">
                <label>国家：</label>
                <input name="country" class="easyui-textbox" required="true">
            </div>
            <div class="fitem">
                <label>客户名</label>
                <input name="client_name" class="easyui-textbox">
            </div>
            <div class="fitem">
                <label>网址：</label>
                <input name="website" class="easyui-textbox" validType="email">
            </div>
			<div class="fitem">
                <label>客户类别：</label>
                <input name="type" class="easyui-textbox" validType="email">
            </div>
			<div class="fitem">
                <label>行业：</label>
                <input name="sector" class="easyui-textbox" validType="email">
            </div>
        </form>
    </div>
    <div id="dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">Save</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
    </div>